package view.geneticAlgorithmDisplays.stringGrid;

import java.awt.BorderLayout;

import javax.swing.JFrame;
import javax.swing.JPanel;


import model.geneticAlgorithm.driver.HelloWorldGeneticAlgorithmDriver;
import model.population.StaticSizePopulation;

public class HelloWorldFrame
{
	
	
	public HelloWorldFrame(HelloWorldGeneticAlgorithmDriver driver)
	{
		JFrame frame = new JFrame("Simple String Genetic Algorithm");
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

		PopulationStringGrid panel = createMainPanel((StaticSizePopulation) driver.getPopulation());
		
		frame.getContentPane().add(panel, BorderLayout.CENTER);
		frame.pack();
		frame.setVisible(true);
		
		driver.attachGenerationListener(panel);
	}

	private PopulationStringGrid createMainPanel(StaticSizePopulation pop)
	{
		return new PopulationStringGrid(pop);
	}

}
